package com.eling.elcms.travel.model;

import com.eling.elcms.community.model.Organization;
import com.eling.elcms.core.dao.annotation.Between;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancer;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancers;
import com.eling.elcms.core.dao.annotation.In;
import com.eling.elcms.core.dao.hibernate.OrderCriteriaEnhancer;
import com.eling.elcms.core.model.BaseModel;
import com.eling.elcms.privilege.service.impl.CommonPrivilegeCriteriaEnhancer;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;

import javax.persistence.*;
import java.util.Date;

/**
 * 旅居 计划制定-子表-子计划
 * 
 * @author sunchenlong
 * 
 * 模型评审：是否限制人数的bool没有必要，可以直接根据人数属性进行判断，wulina 2016-09-07
 * 
 */
@Entity
@Indexed
@Table(name = "travel_planitem")
@CriteriaEnhancers(criteriaEnhancers = {
		@CriteriaEnhancer(impl = OrderCriteriaEnhancer.class, parameter = "startDate:desc"),
		@CriteriaEnhancer(impl = CommonPrivilegeCriteriaEnhancer.class, parameter = "organization:organization") })
public class PlanItem extends BaseModel {

	private static final long serialVersionUID = 3876007601707121723L;

	@Id
	@In
	@DocumentId
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long pkPlanItem;

	/** 所属机构 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkOrganization")
	@IndexedEmbedded(depth = 1)
	private Organization organization;

	/** 目的地 */
	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkDestination")
	@IndexedEmbedded(depth = 1)
	private Destination destination;

	/** 开始日期 */
	@Field
	@Column
	@Between
	private Date startDate;

	/** 结束日期 */
	@Field
	@Column
	private Date endDate;

	/** 是否限制最多人数 */
	@Field
	@Column
	private Boolean limitmax;

	/** max人数 */
	@Field
	@Column
	private Integer maxpeople;

	/** 是否限制最少人数 */
	@Field
	@Column
	private Boolean limitmin;

	/** min人数 */
	@Field
	@Column
	private Integer minpeople;

	/** 是否联盟 */
	@Field
	@Column
	private Boolean alliance;

	/** 联盟单位 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkAllianceOrg")
	@IndexedEmbedded(depth = 1)
	private AllianceOrg allianceOrg;

	/** 应收金额 */
	@Field
	@Column
	private Double receivables;

	@Version
	private Integer version;

	public Long getPkPlanItem() {
		return pkPlanItem;
	}

	public void setPkPlanItem(Long pkPlanItem) {
		this.pkPlanItem = pkPlanItem;
	}

	public Organization getOrganization() {
		return organization;
	}

	public void setOrganization(Organization organization) {
		this.organization = organization;
	}

	public Destination getDestination() {
		return destination;
	}

	public void setDestination(Destination destination) {
		this.destination = destination;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public Boolean getLimitmax() {
		return limitmax;
	}

	public void setLimitmax(Boolean limitmax) {
		this.limitmax = limitmax;
	}

	public Integer getMaxpeople() {
		return maxpeople;
	}

	public void setMaxpeople(Integer maxpeople) {
		this.maxpeople = maxpeople;
	}

	public Boolean getLimitmin() {
		return limitmin;
	}

	public void setLimitmin(Boolean limitmin) {
		this.limitmin = limitmin;
	}

	public Integer getMinpeople() {
		return minpeople;
	}

	public void setMinpeople(Integer minpeople) {
		this.minpeople = minpeople;
	}

	public Boolean getAlliance() {
		return alliance;
	}

	public void setAlliance(Boolean alliance) {
		this.alliance = alliance;
	}

	public AllianceOrg getAllianceOrg() {
		return allianceOrg;
	}

	public void setAllianceOrg(AllianceOrg allianceOrg) {
		this.allianceOrg = allianceOrg;
	}

	public Double getReceivables() {
		return receivables;
	}

	public void setReceivables(Double receivables) {
		this.receivables = receivables;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

}
